package com.ruoyi.web.controller.dianzan.goods;

import com.ruoyi.common.tip.SuccessTip;
import com.ruoyi.common.tip.Tip;
import com.ruoyi.goods.service.IGoodsService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>Description: 商品后台控制层 </p>
 * <p>Created at 2019/8/8 15:32</p>
 * <p>Created by zuo min (myleszelic@outlook.com) </p>
 */
@Controller
@RequestMapping("/goods")
public class GoodsController {

    @Autowired
    private IGoodsService goodsService;

    /**
     * <p>Description: 砍价板view </p>
     * <p>Created at 2019-08-08 15:34 </p>
     * <p>Created by zuo min </p>
     * @return java.lang.String
     */
    @RequiresPermissions("goods:cut:page:view")
    @GetMapping("/cut")
    public String cutView() {
        return "dianzan/goods/cut-page";
    }

    /**
     * <p>Description: 请求砍价板数据 </p>
     * <p>Created at 2019-08-08 16:17 </p>
     * <p>Created by zuo min </p>
     * @param param
     * @return
     */
    @PostMapping("/cutPriceList")
    @ResponseBody
    public Tip getCutPriceList(@RequestParam Map param) {
        try {
            List<Map> res = goodsService.selectCutPriceList(param);
            return new SuccessTip(200, "请求成功", res);
        } catch (Exception exp) {
            exp.printStackTrace();
            return new SuccessTip(300, "请求失败");
        }
    }



}
